All Questions
11 questions
-1votes
3answers
332views
Need to format text file and update based of key value format
I have a file having the below values: cat data.txt server1: calv server2: anot log: /u/log/1 server3: calv server4: anot server5: secd server6: calv LIB_TRGT_calv,anot: /tmp/hello.txt LIB_TRGT_secd: /...
3votes
2answers
10kviews
How to search for a string in a very large file with very long lines?
It turns out I was accidentally using grep wrong yesterday. I just checked my bash history and saw what I was executing: grep search-string-here -f large-file-with-long-lines.txt And that was what ...
-1votes
3answers
72views
Remove a whole line beginning with a pattern occurring anywhere after another pattern
How can I remove any line beginning with --- occurring in any line number after a line containing # Match (the first occurrence in any line number)? EDIT: The relationship between #Match with the ...
1vote
4answers
765views
How to process a column's multiple strings
I have a comma separated file that looks similar to his format: aa.com,1.21.3.4,string1 string2 K=12 K2=23 K3=45 K4=56 bb.com,5.6.7.8,string1 string2 K=66 K2=77 K3=88 K4=99 I want to take ...
0votes
1answer
372views
AWK / String manipulation: How to pull strings out from a column and compare it with a number before printing the row
I have a list of data in a table. By using awk to pull out column 5, i was able to differentiate the data amongst the rows. If the entry at column 5 is more than 4, the row should be printed. ...
-1votes
3answers
670views
Print column with AWK
I am trying to find a way to use awk to start printing only once it finds the search parameter and print only a couple of columns following it. To try to explain a little better I am looking over a ...
1vote
3answers
505views
How to print each line of a file as many times as according to the number in the first column
Input_file: 1 string1 4 string2 2 string3 ... Output_file: 1 string1 4 string2 4 string2 4 string2 4 string2 2 string3 2 string3 ... Here's my code and it didn't work. #!/bin/bash N=0 cat ...
60votes
1answer
129kviews
Remove last character from string captured with awk [duplicate]
I need to remove the last character from a string in this command: sudo docker stats --no-stream 39858jf8 | awk '{if (NR!=1) {print $2}}' The result is 5.20% , I need remove the % at the end, giving ...
3votes
2answers
15kviews
using gsub in awk to replace a word with parentheses
Hi how can I use gsub to replace a word which has parentheses. Here I want to replace ABC(T) with ABC/G awk ' {gsub("ABC\(T\)","ABC/G")}; Print $0' "$FILENAME" > tmp.tmp && mv tmp.tmp "$...
0votes
1answer
208views
replacing first link of a text "awk equivalent of sed command"
I wanted to replace the first line of a text with sed it should be like sed -i.bak "1 s/^.*$/"CompoundState\tMethod\tApproach\tS^2\tEnergy\tPath"/" awk.xls but I also need to run it on OSX but it ...
2votes
2answers
2kviews
How to find and replace a field column value in UNIX
I have file with the value say which is delimited with | 123-|aaa|bbb|123|123.0|123-|123.01-|-123.02|123.03-|aaa|bbb|123-|aaa-|-bbb|cc-cc|123.04-|aa123-|123.05- I need to pick the column values which ...